package dcutils.rpg.items;

/**
 * Represents an item type; E.g.: armor, weapon, potion, etc.
 * @author dca
 */
public class ItemType {
   private int id; // unique identifier
   private String name; // item type name

   public ItemType(String name) {
      this((int)System.currentTimeMillis(), name);
   } // END constructor
   public ItemType(int id, String name) {
      setId(id);
      setName(name);
   } // END constructor

   public int getId() {
      return id;
   } // END getId
   public ItemType setId(int id) {
      this.id = id;
      return this;
   } // END setId

   public String getName() {
      return name;
   } // END getName
   public ItemType setName(String name) {
      this.name = name;
      return this;
   } // END setName

   @Override
   public String toString() {
      return getName();
   } // END toString

   @Override
   public boolean equals(Object obj) {
      if(null == obj) {
         return false;
      } else if(obj instanceof ItemType) {
    	  ItemType itemType = (ItemType)obj;
         return this.getName().equalsIgnoreCase(itemType.getName());
      } else {
         return false;
      } // END if/else
   } // END equals

   @Override
   public int hashCode() {
      int hashCode = 101;
      hashCode = (11 * hashCode) + name.hashCode();
      return hashCode;
   } // END hashCode
} // END class ItemType
